package eva.savant.business.contabilidad.view

import eva.savant.businessobject.cg.Asiento
import eva.savant.businessobject.cg.Partida
import eva.savant.core.view.Bean

import javax.faces.bean.ManagedBean
import javax.faces.bean.SessionScoped
import javax.annotation.PostConstruct

@SessionScoped
@ManagedBean(name = 'IILibroDiario')
public class IILibroDiario extends Bean {

  def debe, haber; Date dateIni, dateEnd

  @PostConstruct
  public void cleanEntity() {

    lsEntity = null

    dateIni= dateEnd= new Date()
  }

  public List findLsEntity() {

    form= true

    debe= get(Partida,'sum(debe): asiento.fecha between ? and ?',toStartDay(dateIni),toMidnight(dateEnd))

    haber= get(Partida,'sum(haber): asiento.fecha between ? and ?',toStartDay(dateIni),toMidnight(dateEnd))

    return find(Asiento,'fecha between ? and ?',toStartDay(dateIni),toMidnight(dateEnd))
  }

}
